using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "FriendMinHpTarget-获得这个棋子的受伤的友方", menuName = "Skill/Target/FriendMinHpTarget-获得这个棋子的受伤的友方")]
public class FriendMinHpTarget : TargetSelectorBase
{
    public override List<Chess> SelectTargets(Chess chess, GameEvent e)
    {
        var differenceHp = 0;
        var list = new List<Chess>();
        var chessList = ChessManager.GetInstance().chessList;
        foreach (var c in chessList)
        {
            if(c.GetChessSide() != chess.GetChessSide()) continue;
            if (c.chessDate.health - c.ChessDetail.OriginalHp > differenceHp)
            {
                list.Clear();
                list.Add(c);
                differenceHp = c.chessDate.health - c.ChessDetail.OriginalHp;
            }
            else if(c.chessDate.health - c.ChessDetail.OriginalHp == differenceHp)
            {
                list.Add(c);
            }
        }
        
        return list;
    }
}